﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ColladaDotNet;

namespace contentviewer.ViewModel
{
    public class AssetViewModel : NodeViewModel
    {
        readonly asset _asset;

        public AssetViewModel(NodeViewModel root, NodeViewModel parent, asset asset)
            : base(root, parent)
        {
            _asset = asset;
        }

        public string Created
        {
            get
            {
                return _asset.created.ToString();
            }
        }

        public string Modified
        {
            get
            {
                return _asset.modified.ToString();
            }
        }

        public string Unit
        {
            get
            {
                return _asset.unit.name;
            }
        }

		public string Content
		{
			get
			{
				return "asset";
			}
		}

		public bool HasContributors
		{
			get 
			{ 
				return !((_asset.contributor == null) || (_asset.contributor.Count() == 0)); 
			}
		}

        protected override void LoadChildren()
        {
            base.LoadChildren();
        }

		public override bool IsSelected
		{
			get
			{
				return base.IsSelected;
			}
			set
			{
				if (value == true)
					(Root as ColladaNodeViewModel).SelectedItems.Add(this);
				else
					(Root as ColladaNodeViewModel).SelectedItems.Remove(this);
				base.IsSelected = value;
			}
		}

		public override string ToString()
		{
			return this.Content;
		}
    }
}
